package com.zeratul.common.i18n.config;

import com.zeratul.common.i18n.web.flux.WebFluxI18nFilter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.server.WebFilter;

/**
 * 基于Flux模式的国际化配置
 */
@AutoConfiguration
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE)
@ConditionalOnProperty(prefix = "i18n.config", name = "enabled", havingValue = "true", matchIfMissing = true)
@Slf4j
public class I18nWebFluxAutoConfiguration {

    /**
     * 国际化请求-语言环境拦截器
     * @return
     */
    @Bean
    public WebFilter i18nWebFilter() {
        log.debug("Flux模式-国际化语言环境加载");
        return new WebFluxI18nFilter();
    }
}
